﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DTO;
using DAO;

namespace QLDaiLy
{
    public partial class DanhSachNhanVienMoi :XtraUserControl
    {
        private int MaChucVu;

        public DanhSachNhanVienMoi()
        {
            InitializeComponent();
            LoadDSNhanVienMoi();
        }

        public DanhSachNhanVienMoi(int MaChucVu)
        {
            // TODO: Complete member initialization
            InitializeComponent();
            LoadDSNhanVienMoi();
            this.MaChucVu = MaChucVu;
            if (MaChucVu == 1)
            {
                gridViewDanhSachNhanVien.Columns["Delete"].Visible = true;
                gridViewDanhSachNhanVien.Columns["CapNhat"].Visible = false;
                gridViewDanhSachNhanVien.Columns["PhanQuyen"].Visible = true;

            }
            if (MaChucVu == 2)
            {
                gridViewDanhSachNhanVien.Columns["Delete"].Visible = false;
                gridViewDanhSachNhanVien.Columns["CapNhat"].Visible = false;
                gridViewDanhSachNhanVien.Columns["PhanQuyen"].Visible = false;
            }
            if (MaChucVu == 3)
            {
                gridViewDanhSachNhanVien.Columns["Delete"].Visible = false;
                gridViewDanhSachNhanVien.Columns["CapNhat"].Visible = true;
                gridViewDanhSachNhanVien.Columns["PhanQuyen"].Visible = false;
            }
            if (MaChucVu == 4)
            {

                gridViewDanhSachNhanVien.Columns["Delete"].Visible = false;
                gridViewDanhSachNhanVien.Columns["CapNhat"].Visible = false;
                gridViewDanhSachNhanVien.Columns["PhanQuyen"].Visible = false;
            }
            if (MaChucVu == 5)
            {
                gridViewDanhSachNhanVien.Columns["Delete"].Visible = false;
                gridViewDanhSachNhanVien.Columns["CapNhat"].Visible = false;
                gridViewDanhSachNhanVien.Columns["PhanQuyen"].Visible = false;
            }
        }
        private void LoadDSNhanVienMoi()
        {
            List<NhanVienDTO> list = new List<NhanVienDTO>();
            list = NhanVienDAO.LoadDanhSachNVCoMaCV();
            gridNhanVienControl.DataSource = list;
        }
        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void repositoryItemPicturePhanQuyen_Click(object sender, EventArgs e)
        {
            MessageBox.Show("ok");
        }

        private void repositoryItemPictureCapNhat_Click(object sender, EventArgs e)
        {

            MessageBox.Show("cap nhật");
        }

        private void repositoryItemPictureDelete_Click(object sender, EventArgs e)
        {
            MessageBox.Show("xoá");
        }

        private void gridViewDanhSachNhanVien_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
        {
            if (e.Column.Caption == "CapNhat")
            {
                e.Value = QLDaiLy.Properties.Resources.updateUser;
            }
            if (e.Column.Caption == "Delete")
            {
                e.Value = QLDaiLy.Properties.Resources.delete;
            }
            if (e.Column.Caption == "Phân Quyền")
            {
                e.Value = QLDaiLy.Properties.Resources.add_user;
            }
        }
    }
}
